<?php
declare (strict_types=1);

namespace app\login\middleware;

use app\api\server\Token;

class Check
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        // 判断用户是否登录
        $uid = Token::verifyToken();
        if ($uid) {
            $request->uid = $uid;
            return $next($request);
        } else {
            return json(['data' => [], 'code' =>1001, 'msg' =>'请登录']);

        }
    }
}
